/*
 * @project-name workflow
 * @Description:
 * @author lenovo
 * @date 2021/6/29 14:05
 * @file user
*/
'use strict';
const moment = require('moment');

module.exports = app => {
    const mongoose = app.mongoose;
    const Schema = mongoose.Schema;
    const ObjectId = mongoose.Schema.Types.ObjectId;

    const UserSchema = new Schema({
        userName: { type: String, unique: true, trim: true },
        password: { type: String, trim: true, },
        organization: {
            type: ObjectId
        },
        birthday: {
            type: Number,
        },
        isLogin: {
            type: Boolean,
            default: false,
        },
        isUsing: {
            type: Boolean,
            default: true,
        },
        isDelete: {
            type: Boolean,
            default: false,
        },
        createdTime: { type: Number },
        updatedTime: { type: Number },
    }, {
        versionKey: false,
        timestamps: {
            createdAt: 'createdTime',
            updatedAt: 'updatedTime',
            currentTime: () => Date.now()
        }
    });

    return mongoose.model('User', UserSchema, 'user');
}